import Axios from 'axios'

Axios.defaults.baseURL = 'http://127.0.0.1:3000'

Axios.interceptors.response.use(
  function (response) {
    return response.data
  },
  function (error) {
    console.error(error)
  },
)

export const TableList = function (params) {
  return Axios.get('/table', {
    params: params,
  })
}

export const TableFieldsList = function (params) {
  return Axios.get('/table/fields', {
    params: params,
  })
}


export const ImageSearch = function (params) {
  return Axios.get('/api/images/search', {
    params: params,
  })
}

export const GetStudentStyleMeta = function() {
  return Axios.get("/api/images/student-style/meta")
}

export const GetGraduationMajors = function() {
  return Axios.get("/api/images/graduation/majors")
}


export const GetGraduationYearsByMajor = function(major) {
  return Axios.get("/api/images/graduation/years?major=" + major)
}


export const GetStudentsById = function(student_id) {
  return Axios.get("/api/students/by-id?student_id=" + student_id)
}



export const GetStudentsByName = function(major) {
  return Axios.get("/api/students/by-name?name=" + major)
}

